/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hourupdate.network.connection;

import java.sql.Connection;
import java.sql.DriverManager;

import org.apache.log4j.Logger;

/**
 * @author Windows7
 * Servlet implementation class  ConnectionJDBC
 * Program : ConnectionJDBC
 * Create By : Wachiranon Aryuwong
 * Create Date : 19/05/2556
 * Modify By :
 * Modify Date :
 */
public class ConnectionJDBC {
	static final Logger logger = Logger.getLogger(ConnectionJDBC.class);
	public static final String schema = ConnectionProperties.getconResourceString("database");
	public static final String schemaBANNER = ConnectionProperties.getconResourceString("schemaBANNER");
	public static final String schemaCHANNEL_DETAIL_NEWS = ConnectionProperties.getconResourceString("schemaCHANNEL_DETAIL_NEWS");
	public static final String schemaCHANNEL_NEWS = ConnectionProperties.getconResourceString("schemaCHANNEL_NEWS");
	public static final String schemaRUNNING = ConnectionProperties.getconResourceString("schemaRUNNING");
	public static final String schemaSEND_MASSAGE_TIME = ConnectionProperties.getconResourceString("schemaSEND_MASSAGE_TIME");
	
    /**
     *
     * @return
     */
    public Connection getJDBConnection() {
       Connection connection = null;
        try {
            Class.forName(ConnectionProperties.getconResourceString("DBDriver"));
            connection = DriverManager.getConnection(ConnectionProperties.getconResourceString("JdbcDB")+ConnectionProperties.getconResourceString("database")+"?characterEncoding=UTF-8", ConnectionProperties.getconResourceString("Username"), ConnectionProperties.getconResourceString("Password"));
            if (connection == null) {
                logger.info("Connection is connect");
            }
            connection.setAutoCommit(false);
        } catch (ClassNotFoundException e) {
        	logger.error(e.getMessage());
        } catch (Exception e) {
        	logger.error(e.getMessage());
        }
        return connection;
    }
}
